package com.hanlink.dsp;

import com.blankj.utilcode.util.SPUtils;
import com.hanlink.dsp.model.UserProfile;
import com.hanlink.dsp.ca.model.settings.AdvanceSettings;
import com.hanlink.dsp.ca.model.settings.EqSettings;
import com.hanlink.dsp.ca.model.settings.HomeSettings;
import com.hanlink.dsp.ca.model.settings.PlaySettings;
import com.hanlink.dsp.ca.model.settings.SummingSettings;
import com.hanlink.dsp.ca.model.settings.XoverSettings;
import com.hanlink.dsp.protocols.DspProtocol;
import com.hanlink.dsp.util.DataUtil;

/**
 * Created by zhanghb on 2015-11-29.
 */
public class DspSettings {



    public static String MODEL_VALUE = "";

    public static boolean MUSIC_ON = false;

    public static int CHANNEL_LENGTH = 8;

    public static boolean isSupportGroupAll = CHANNEL_LENGTH == 6;

    public static int FRENCY_LENGTH = 31;

    public final static int MAX_TIME_DELAY = 800;
    public final static int MAX_TIME_DELAY_EZ = 1000;

    public static int MAX_LED_BRIGHT = 8;

    public static boolean reset = false;

    //CHANNEL_TYPE_2(0),  CHANNEL_TYPE_4_1(3)
    public enum ChannelType {
        CHANNEL_TYPE_2_1(1), CHANNEL_TYPE_7_1(2),
        ;

        int typeCode;

        ChannelType(int typeCode) {
            this.typeCode = typeCode;
        }

        public int getTypeCode() {
            return typeCode;
        }

    }

    public static ChannelType parseType(int typeCode) {
        switch (typeCode) {
/*            case 0:
                return ChannelType.CHANNEL_TYPE_2;*/
            case 1:
                return ChannelType.CHANNEL_TYPE_2_1;
            case 2:
                return ChannelType.CHANNEL_TYPE_7_1;
/*            case 3:
                return ChannelType.CHANNEL_TYPE_4_1;*/
        }
        return ChannelType.CHANNEL_TYPE_2_1;
    }

    /**
     * 当前默认的Type类型
     */
    public static ChannelType CURRENT_CHANNEL_TYPE = ChannelType.CHANNEL_TYPE_7_1;

    /**
     * 过去的Type
     */
    public static ChannelType OLD_CHANNEL_TYPE_CHANGED = ChannelType.CHANNEL_TYPE_2_1;


    public static int CURRENT_TAB = 0;


    public static int CURRENT_EQ_INDEX = 0;

    public static final UserProfile DEFAULT_USERP_PROFILE;

    static {
        DEFAULT_USERP_PROFILE = new UserProfile();
        DEFAULT_USERP_PROFILE.setName("_._de_fault_._");
        DEFAULT_USERP_PROFILE.setId(1);
    }

    private static UserProfile mUserProfile; //当前的默认Profile

    public static void setUserProfile(UserProfile userProfile){
        mUserProfile = userProfile;
    }
    public static UserProfile getUserProfile() {
        if (mUserProfile == null) {
            synchronized (DspSettings.class){
                if(mUserProfile == null){
                    int saveId = SPUtils.getInstance().getInt("user_profile_id",-1);
                    if (saveId == -1){//没有

                        mUserProfile = DEFAULT_USERP_PROFILE;
                    }else {
                        mUserProfile = new UserProfile();
                        mUserProfile.setId(saveId);
                    }
                }
            }
            return  DEFAULT_USERP_PROFILE;

        }
        return mUserProfile;
    }
    public static void updateUserProfile(UserProfile userProfile) {
        mUserProfile = userProfile;
        SPUtils.getInstance().put("user_profile_id",userProfile.getId());
    }

    public static  HomeSettings HOME_SETTINGS = new HomeSettings();

    public static  SummingSettings SUMMING_SETTINGS = new SummingSettings();

    public static EqSettings EQ_SETTINGS = new EqSettings();

    public static XoverSettings XOVER_SETTINGS = new XoverSettings();

    public static AdvanceSettings ADVANCE_SETTINGS = new AdvanceSettings();

    public static PlaySettings PLAY_SETTINGS = new PlaySettings();


}
